#centos Base Image
FROM registry.cn-hangzhou.aliyuncs.com/jc76439984/centos-base:6

MAINTAINER  jc "76439984@qq.com"

RUN mkdir /home/tools 
WORKDIR /home/tools

# 安装nginx
RUN yum -y install nginx

# 安装tomcat+jdk
COPY tomcat/* /home/tools/
RUN rpm -ivh jdk-8u181-linux-x64.rpm && \
tar xfz apache-tomcat-8.5.32.tar.gz && \
mv apache-tomcat-8.5.32 /home/tomcat8

# 安装mysql
COPY mysql/* /home/tools/ 
RUN yum -y localinstall Mar*

# 安装mongodb
RUN yum -y install net-snmp-libs
COPY mongodb/* /home/tools/
RUN tar xfz mongodb-linux-x86_64-enterprise-rhel62-3.0.6.tgz && \
cp mongodb-linux-x86_64-enterprise-rhel62-3.0.6/bin/* /usr/bin/

# 安装nodejs
RUN yum -y install git && \
export NVM_DIR=/opt/nvm && \
curl -k https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash && \
NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node && \
source ~/.bash_profile && \
nvm install v4.1.1 && \
nvm alias default 4.1.1 && \
npm config set registry http://registry.npm.taobao.org && \
npm install pm2@1.1.3 -g && \
pm2 startup centos && \
mv /etc/init.d/pm2{-init.sh,}

# 安装zlog
COPY radius/zlog-latest-stable.tar.gz /home/tools/
RUN tar xfz zlog-latest-stable.tar.gz && cd zlog-latest-stable && \
make && make install && \
echo "/usr/local/lib" >> /etc/ld.so.conf && \
ldconfig

# 安装radius
RUN useradd radius && echo "radius" | passwd --stdin radius
ADD radius/radius_iGuangdong.tar.gz /home/radius/
RUN cd /home/radius/ && \
chown -R radius:radius radius_iGuangdong/ && \
cd /home/radius/radius_iGuangdong/sbin/ && \
chmod +x rc.radiusd.iGuangdong && \
cp rc.radiusd.iGuangdong /etc/init.d/ && \
export LD_LIBRARY_PATH=/home/radius/radius_iGuangdong/lib && \
yum -y install libtalloc freeradius-utils.x86_64

# 环境清理
RUN yum clean all && \	
rm -fr /home/tools

EXPOSE 80 8080 3306 

ADD app_init.sh /bin/
RUN chmod +x /bin/app_init.sh


CMD ["/usr/bin/monit","-I"]

ENTRYPOINT ["/bin/app_init.sh"]